package cn.edu.scau.cmi.wujiaxian.composite.consistent;

import java.util.HashSet;
import java.util.Set;

public abstract class Organization {
	
	
	// 名字
	private String name;

	//	(1)父节点。
	private Organization parent = null;
	
	//	(2)子节点作为其组成部分。
	private Set<Organization> children = new HashSet<Organization>();
		
	public Organization(Organization parent, String name) {
		this.name = name;
		this.parent = parent;
	}

	//	(3)业务功能
	abstract String toString(int cent);
	
	//	(4)对包含对象的功能
	public Organization getParent() {
		return parent;
	}

	public void setParent(Organization parent) {
		this.parent = parent;
	}
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	//	(5)对构成部分管理的功能，这些和安全性组合模式不同
	public void addChild(Organization child) {
		children.add(child);
	}
	
	public void removeChild(Organization child){
		children.remove(child);
	}
	
	public Set<Organization> getChildren() {
		return children;
	}

	public void setChildren(Set<Organization> children) {
		this.children = children;
	}
	
}
